package main.model;

import main.controller.GEDIVAController;
import main.controller.MVCObservable;


/**
 * @author Yaqi Zhang, Kevin Gao, Michele Reshef
 */
public abstract class DataModel extends MVCObservable implements Iterable<Day> {

    private String myName = "N/A";

    /**
     * For constructing and adding the controller as an observer.
     *
     * @param controller The controller for the model
     */
    public DataModel (GEDIVAController controller) {
        super(controller);
    }

    /**
     * Special constructor that doesn't need a controller. This means that
     * events won't work. This is really only used for NullModel.
     */
    protected DataModel () {
    }

    /**
     * @return return the model name
     */
    public String getName () {
        return myName;
    }

    /**
     * @param name Name to set
     * @return
     */
    public void setName (String name) {
        myName = name.replaceAll(",+$", "");
    }

    /**
     * @return the Row that has maximum High value, need this to decide the axis
     *         range.
     */
    public abstract Day getMaxRow ();

    /**
     * @return the Row that has minimum Low value, need this to decide the axis
     *         range.
     */
    public abstract Day getMinRow ();

    /**
     * @return the first Row
     */
    public abstract Day getFirstRow ();

    /**
     * @return return the last Row
     */
    public abstract Day getLastRow ();

    /**
     * @return the number of Rows in the list.
     */
    public abstract int getSizeOfData ();

    /**
     * Adds a new row to the data model.
     *
     * @param d row to add
     */
    public abstract void addRow (Day d);

    /**
     * Determines whether the data set is empty.
     *
     * @return whether or not the data set is empty
     */
    public abstract boolean isEmpty ();

}
